const Resume = require("../model/resume");
module.exports = {
    // 获取个人信息
    getResumeInfo: (req, res, next) => {
        const { userId } = req.query;
        Resume.getResumeInfo(userId)
            .then((res) => {
                req.resumeInfo = res;
                next();
            })
            .catch((err) => {
                next(err);
            });
    },
    getProject:(req, res, next)=> {
        const { userId } = req.query;
        Resume.getProject(userId)
            .then((res) => {
                req.resumeInfo = res;
                next();
            })
            .catch((err) => {
                next(err);
            });
    },
    // 个人信息修改与添加
    updatePersonalInfo: (req, res, next) => {
        const personalInfo = req.body;
        console.log(personalInfo);
        // resume.time = getNowFormatTime();
        Resume.updatePersonalInfo(personalInfo)
            .then((resolve) => {
                req.data = resolve;
                next();
            })
            .catch((err) => {
                next(err);
            });
    },
    // 社交链接修改与添加
    updateSocialLinks: (req, res, next) => {
        const linkInfo = req.body;
        // resume.time = getNowFormatTime();
        Resume.updateSocialLinks(linkInfo)
            .then((resolve) => {
                req.data = resolve;
                next();
            })
            .catch((err) => {
                next(err);
            });
    },
    // 技能链接修改与添加
    updateSkill: (req, res, next) => {
        const skillInfo = req.body;
        // resume.time = getNowFormatTime();
        Resume.updateSkill(skillInfo)
            .then((resolve) => {
                req.data = resolve;
                next();
            })
            .catch((err) => {
                next(err);
            });
    },
    // 项目修改与添加
    updateProject: (req, res, next) => {
        const projectInfo = req.body;
        // resume.time = getNowFormatTime();
        Resume.updateProject(projectInfo)
            .then((resolve) => {
                req.data = resolve;
                next();
            })
            .catch((err) => {
                next(err);
            });
    },
    // 工作信息修改与添加
    updateWork: (req, res, next) => {
        const workInfo = req.body;
        // resume.time = getNowFormatTime();
        Resume.updateWork(workInfo)
            .then((resolve) => {
                req.data = resolve;
                next();
            })
            .catch((err) => {
                next(err);
            });
    },
    // 学历信息修改与添加
    updateEducation: (req, res, next) => {
        const educationInfo = req.body;
        // resume.time = getNowFormatTime();
        Resume.updateEducation(educationInfo)
            .then((resolve) => {
                req.data = resolve;
                next();
            })
            .catch((err) => {
                next(err);
            });
    },
    del: (req, res, next) => {
        const { enumeration, id } = req.query;
        Resume.del(enumeration, id)
            .then((resolve) => {
                req.data = resolve;
                next();
            })
            .catch((err) => {
                next(err);
            });
    }
}